<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 异步语句
    // 为了保证后期能被清楚，需要赋值一个变量
    // 参数为0的时候也是先同步后异步
    var stime = window.setTimeout(function () {
      console.log("time");
    },1000);

    function fun() {
      console.log("w");
    }
    var stimes = window.setTimeout(fun,10000);

    console.log(stime);
    console.log(stimes);
    // 同步语句
    console.log(1);
    console.log(2);
    // 清楚延时器
    clearTimeout(stime);
  </script>
</body>
</html>